load("//bazel:tachyon_cc.bzl", "tachyon_cc_library", "tachyon_cc_unittest")

package(default_visibility = ["//visibility:public"])

tachyon_cc_library(
    name = "key",
    hdrs = ["key.h"],
    deps = [
        ":toxic_waste",
        "//tachyon:export",
        "//tachyon/math/elliptic_curves/msm:fixed_base_msm",
        "//tachyon/math/polynomials/univariate:univariate_evaluation_domain",
        "//tachyon/zk/r1cs/constraint_system:circuit",
        "//tachyon/zk/r1cs/constraint_system:qap_instance_map_result",
        "@com_google_absl//absl/types:span",
    ],
)

tachyon_cc_library(
    name = "prepared_verifying_key",
    hdrs = ["prepared_verifying_key.h"],
    deps = [
        ":verifying_key",
        "//tachyon/math/elliptic_curves/pairing",
    ],
)

tachyon_cc_library(
    name = "proof",
    hdrs = ["proof.h"],
    deps = ["@com_google_absl//absl/strings"],
)

tachyon_cc_library(
    name = "prove",
    hdrs = ["prove.h"],
    deps = [
        ":proof",
        ":proving_key",
        "//tachyon/base:optional",
        "//tachyon/base:profiler",
        "//tachyon/device/gpu:scoped_mem_pool",
        "//tachyon/device/gpu:scoped_stream",
        "//tachyon/math/elliptic_curves/msm:variable_base_msm",
        "//tachyon/math/elliptic_curves/msm:variable_base_msm_gpu",
        "//tachyon/zk/r1cs/constraint_system:qap_witness_map_result",
    ],
)

tachyon_cc_library(
    name = "proving_key",
    hdrs = ["proving_key.h"],
    deps = [
        ":verifying_key",
        "//tachyon/base:maybe_owned",
    ],
)

tachyon_cc_library(
    name = "toxic_waste",
    hdrs = ["toxic_waste.h"],
    deps = ["@com_google_absl//absl/strings"],
)

tachyon_cc_library(
    name = "verify",
    hdrs = ["verify.h"],
    deps = [
        ":prepared_verifying_key",
        ":proof",
        "//tachyon/base:profiler",
        "//tachyon/math/elliptic_curves/msm:variable_base_msm",
        "//tachyon/math/geometry:point_conversions",
    ],
)

tachyon_cc_library(
    name = "verifying_key",
    hdrs = ["verifying_key.h"],
    deps = [
        ":key",
        "//tachyon/base:maybe_owned",
        "//tachyon/base:openmp_util",
        "//tachyon/base:optional",
        "//tachyon/base/strings:string_util",
    ],
)

tachyon_cc_unittest(
    name = "groth16_unittests",
    srcs = ["groth16_unittest.cc"],
    deps = [
        ":prove",
        ":verify",
        "//tachyon/math/elliptic_curves/bn/bn254",
        "//tachyon/math/polynomials/univariate:univariate_evaluation_domain_factory",
        "//tachyon/zk/r1cs/constraint_system:quadratic_arithmetic_program",
        "//tachyon/zk/r1cs/constraint_system/test:simple_circuit",
    ],
)
